function xOut=mtimes(x1,x2)

nx1 = size(x1);
nx2 = size(x2);

nr = nx1(1);
nc = nx2(2);

nd = size(x1.d,3);

xOut = deriv1f(zeros(nr,nc),0,nd);

s1.type = '()';
s1.subs = {0,':'};
s2.type = '()';
s2.subs = {':',0};
s.type = '()';
for(i=1:nr)
  s1.subs{1} = i;
  xi = subsref(x1,s1);
  for j=1:nc
    s2.subs{2} = j;
    xj = subsref(x2,s2);
    xx = dot(xi,xj);
    xOut.v(i,j) = xx.v;
    xOut.d(i,j,:) = xx.d;
    %s.subs = {i,j};
    %xOut = subsasgn(xOut,s,dot(xi,xj));
  end
end

